package com.wanxi.news.controller;


import com.wanxi.common.entity.NewsModel;
import com.wanxi.common.result.ResultDTO;
import com.wanxi.common.util.Tool;
import com.wanxi.news.service.impl.NewsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class NewsController {

    @Autowired
    private NewsServiceImpl newsService;

    @RequestMapping("/back/news/findAll")
    public ResultDTO findAll(NewsModel news) {

        ResultDTO resultDTO = newsService.findAll(news);
        return resultDTO;
    }

    @RequestMapping("/back/news/add")
    public ResultDTO add(NewsModel news) {
        ResultDTO resultDTO = newsService.add(news);
        return resultDTO;
    }

    @RequestMapping("/back/news/delete")
    public ResultDTO delete(NewsModel news) {
        ResultDTO resultDTO = newsService.delete(news);
        return resultDTO;
    }

    @RequestMapping("/back/news/findById")
    public ResultDTO findById(NewsModel news) {
        ResultDTO resultDTO = newsService.findById(news);
        return resultDTO;
    }

    @RequestMapping("/back/news/update")
    public ResultDTO update(NewsModel news) {
        ResultDTO resultDTO = newsService.update(news);
        return resultDTO;
    }

}
